

function saveUserInfoToken(token){
    localStorage.setItem("EosSoftToken",token);
}

function getUserInfoToken(){
    return localStorage.getItem("EosSoftToken");
}

function saveUserInfoJson(userInfoJson){
    localStorage.setItem("UserInfo",userInfoJson);
}
function getUserInfo(){
    const json = localStorage.getItem("UserInfo");
    try{
        return JSON.parse(json);
    }catch(err){
        console.error("解析json对象异常");
        return null;
    }
}

function setLoginStatus(status){
    if(status){
        localStorage.setItem("logined",true);
    }else{
        localStorage.removeItem("logined")
        localStorage.removeItem("EosSoftToken")
        localStorage.removeItem("UserInfo");
    }
}

function getLoginStatus(){
    return localStorage.getItem("logined");
}


/** return url */
function saveReturnUrl(returnUrl){
    localStorage.setItem("returnUrl",returnUrl);
}
function getReturnUrl(){
    return localStorage.getItem("returnUrl");
}
function clearReturnUrl(){
    localStorage.removeItem("returnUrl");
}


function saveCodeValidation(validationCode){
    localStorage.setItem("ValidCode",validationCode);
}
function getCodeValidation(){
    return localStorage.getItem("ValidCode");
}

/**
 * 个人中心缓存数据
 * @param {*} data 
 */
function saveMineData(data){
    localStorage.setItem("cache_mine_page",JSON.stringify(data));
}
function getMineData(){
    try{
        const data = localStorage.getItem("cache_mine_page");
        return data?JSON.parse(data):null;
    }catch(e){
        return null;
    }
}


function saveConfirmReceiveList(data){
    localStorage.setItem("cache_confirm_receive_page",JSON.stringify(data));
}
function getConfirmReceiveList(){
    try{
        const data = localStorage.getItem("cache_confirm_receive_page");
        return JSON.parse(data)
    }catch(e){
        return null;
    }
}


function setRegisterInfo(key,value){
    const obj = localStorage.getItem("registerInfo");
    let tmp
    if(!obj){
        mp = {[key] : value}
    }else{
        try{
            tmp = JSON.parse(obj);
        }catch(err){
            tmp = {};
        }
        
        tmp[key]=value
    }
    localStorage.setItem("registerInfo",JSON.stringify(tmp));
}
function getRegisterInfo(){
    return JSON.parse(localStorage.getItem("registerInfo")||"{}")
}

function saveCPH(cphArr){
    localStorage.setItem("add_command_cph",JSON.stringify(cphArr))
}
function getCPH(){
    return JSON.parse(localStorage.getItem("add_command_cph"));
}




function cleanCPH(key){
    localStorage.removeItem("add_command_cph")
}


function clearRegisterInfo(){
    localStorage.removeItem("ValidCode");
    localStorage.removeItem("registerInfo");
}


function saveRedirect(url){
    localStorage.setItem("rgb(229,86,77)irect",url);
}
function getRedirect(){
    return localStorage.getItem("rgb(229,86,77)irect");
}
function clearRedirect(){
    localStorage.removeItem("rgb(229,86,77)irect")
}


function saveCommandList(currentPage,data,activeKey,searchKey,scrollY){
    const tmp = {
        currentPage,data,activeKey,searchKey,scrollY
    }
    localStorage.setItem("command_list_cache",JSON.stringify(tmp));
}
function getCommandList(){
    try{
        const tmp = localStorage.getItem("command_list_cache");
        return JSON.parse(tmp);
    }catch(err){
        return null;
    }
}

function saveAllowGetProduct(currentPage,data,activeKey,searchKey,scrollY){
    const tmp = {
        currentPage,data,activeKey,searchKey,scrollY
    }
    localStorage.setItem("allow_get_product_list_cache",JSON.stringify(tmp));
}
function getAllowGetProductList(){
    try{
        const tmp = localStorage.getItem("allow_get_product_list_cache");
        return JSON.parse(tmp);
    }catch(err){
        return null;
    }
}

function saveReceiveConfirm(currentPage,data,activeKey,searchKey,scrollY){
    const tmp = {
        currentPage,data,activeKey,searchKey,scrollY
    }
    localStorage.setItem("receive_confirm_cache",JSON.stringify(tmp));
}
function getReceiveConfirm(){
    try{
        const tmp = localStorage.getItem("receive_confirm_cache");
        return JSON.parse(tmp);
    }catch(err){
        return null;
    }
}